import QtQuick
import QtQuick.Controls

Item {
    id: root
    anchors.fill: parent
    property string imgPath: "../image/anim/skin__caoxiancaohua-daiji/"

    property var frames: (function() {
        var arr = []; 
        for (var i = 0; i <= 120; i++) {
            arr.push(imgPath + i + ".png");
        }
        return arr;
    })()
    
    Image {
        id: animator
        anchors.centerIn: parent
        width: parent.width*0.5
        height: (sourceSize.height/sourceSize.width) * width
        source: frames[currentFrame]
        asynchronous: false
        cache: false
    }
    
    property int currentFrame: 0
    
    Timer {
        interval: 40 // 25帧/秒
        running: true
        repeat: true
        onTriggered: {
            currentFrame = (currentFrame + 1) % frames.length
            animator.source = ""
            animator.source = frames[currentFrame]
        }
    }
}